<?php
header("Content-type: application/json");
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
$get = $_GET;
$data = array();
switch ($request_method)  
{
    case "post":
        $data = $_POST;
        break;
    case "put":
        parse_str(file_get_contents('php://input'), $put_vars);
        $data = $put_vars;
        break;
}
$json = array(
    "type" => $request_method,
    "get" => print_r($get, true),
    "data" => print_r($data, true)
);
echo json_encode($json);
?>